package com.yxp.manager.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yxp.manager.common.DataGrid;
import com.yxp.manager.common.Pagination;
import com.yxp.manager.mapper.AccountMapper;
import com.yxp.manager.model.AccountModel;
import com.yxp.manager.modelVo.request.AccountPageReqVo;
import com.yxp.manager.modelVo.response.AccountPageRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/system/member")
public class MemberController {

    @Autowired
    AccountMapper accountMapper;

    @RequestMapping
    public void index() {

    }

    @RequestMapping("/list")
    @ResponseBody
    public DataGrid<AccountModel> list(int page, int rows, String address) {
//        PageHelper.startPage(page, rows);
        Pagination<AccountPageRespVo> pager = new Pagination<>(page, rows);
        AccountModel accountPageReqVo = new AccountModel();
        accountPageReqVo.setAddress(address);
        Pagination<AccountPageRespVo> respVoPagination = accountMapper.selectAccountByPage(pager, accountPageReqVo);
//        PageInfo<AccountModel> pageRespVoPageInfo = new PageInfo<>(accountMapper.selectList(Wrappers.<AccountModel>lambdaQuery().eq(AccountModel::getAddress, address)));
        return new DataGrid<>(respVoPagination);
    }
}
